import jdk.swing.interop.SwingInterOpUtils;

import javax.swing.tree.TreeNode;
import java.util.List;
import java.util.Stack;

import static java.lang.Math.E;
import static javax.print.attribute.standard.MediaSizeName.B;
import static javax.print.attribute.standard.MediaSizeName.D;

public class Test {
    public static void main(String[] args) {
        TestBinaryTree testBinaryTree=new TestBinaryTree();

        TestBinaryTree.TreeNode root= testBinaryTree.createTree();
        testBinaryTree.preOrder(root);
        System.out.println();
        testBinaryTree.preOrder2(root);
        System.out.println();
        testBinaryTree.inOrder2(root);
        System.out.println();
        testBinaryTree.postOrder2(root);
        System.out.println();
//        testBinaryTree.inOrder(root);
//        System.out.println();
//        testBinaryTree.postOrder(root);
//        System.out.println();
//        System.out.println(testBinaryTree.size(root));
//        System.out.println();
//        testBinaryTree.size2(root);
//        System.out.println(testBinaryTree.nodeSize);
//        System.out.println(testBinaryTree.getLeafNodeCount(root));
//        testBinaryTree.getLeafNodeCount2(root);
//        System.out.println(testBinaryTree.leafsize);
//        int ret=testBinaryTree.getLevelNodeCount(root,3);
//        System.out.println(ret);
//        int height=testBinaryTree.getHeight(root);
//        System.out.println(height);
//        TestBinaryTree.TreeNode retN=testBinaryTree.find(root,'E');//内部类接收
//        if (retN==null){
//            System.out.println("没找到");
//        }else {
//            System.out.println(retN.val);
//        }
      //  TestBinaryTree.TreeNode retY=testBinaryTree.invertTree(root);
        //System.out.println(retY);
//     boolean rr= testBinaryTree.isBalanced(root);
//        System.out.println(rr);
//        boolean kk=testBinaryTree.isSymmetric(root);
//        System.out.println(kk);
//      System.out.println("层序遍历");
//        testBinaryTree.levelOrder(root);
//       System.out.println();
//        System.out.println("分层遍历");
//
//        List<List<Character>> yy=testBinaryTree.levelOrder2(root);
//        System.out.println(yy);
        //找最深公共节点(E,H)需要new出来，不然是局部变量无法在方法外使用
     /////new TestBinaryTree.TreeNode('E');
//        new TestBinaryTree.TreeNode('G');
     //  TestBinaryTree.TreeNode E=root.left.right;
//        TestBinaryTree.TreeNode G=root.right.right;
//        TestBinaryTree.TreeNode qq=testBinaryTree.lowestCommonAncestor(root,E,G);
//        System.out.println(qq.val);
//        System.out.println();

        System.out.println("前序遍历构建二叉树");
        char[] preorder = {'A','B','D','E','H','C','F','G'};
        char[] inorder = {'D','B','E','H','A','F','C','G'};  //改称DBEHAFCG  这个放进去就行了
        char[]postOrder={'D','H','E','B','F','G','C','A'};
        TestBinaryTree.TreeNode cc=testBinaryTree.buildTree(preorder,inorder,0,preorder.length-1);
        testBinaryTree.preOrder(cc);
        System.out.println("后序遍历构建二叉树");
        TestBinaryTree.TreeNode hou=testBinaryTree.buildTree2(preorder,inorder,0,7);
        testBinaryTree.preOrder(hou);

        
    }

}
